﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace Jy123.Web.Manage.User.Guess
{
    public partial class GuessType : MgConfig
    {
        protected int pagesize = 10;
        protected int cpage = 1;//当前页
        protected List<int?> count;

        Jy123.Model.User_Guess_Type modelType = new Jy123.Model.User_Guess_Type();
        Jy123.BLL.User_Guess_Type bllType = new Jy123.BLL.User_Guess_Type();

        protected void Page_Load(object sender, EventArgs e)
        {
            int userID;
            string strUserIdFromCookie = Common.Cookie.getCookie("UserID");
            if (string.IsNullOrEmpty(strUserIdFromCookie))
            {
                Response.Redirect("/");
            }
            userID = int.Parse(strUserIdFromCookie);
           
            string type = "";
            if (!IsPostBack)
            {
                ShowTypeList();
            }
           
            if (!string.IsNullOrEmpty(Request.QueryString["Type"]))
            {
                 type = Request.QueryString["Type"];
            }
            if (type == "del")   //删除
            {
                bllType.Delete(Convert.ToInt32(Request.QueryString["id"]));
                ShowTypeList();
            }
            if (type == "up")    //更新
            {
                modelType.TypeName = Request.QueryString["Name"];
                modelType.TypeAccount = Request.QueryString["Acc"];
                modelType.ID = Convert.ToInt32(Request.QueryString["id"]);
                bllType.Update(modelType);
                ShowTypeList();
            }
                                 
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            modelType.TypeName = txtTypeName.Text;
            modelType.TypeAccount = txtTypeAccount.Text;

            bllType.Add(modelType);
            ShowTypeList();
            MessageBox("添加成功", MsgType.ok);
            
        }

        /// <summary>
        /// 加载竞猜类别信息列表
        /// </summary>
        private void ShowTypeList()
        {
            Rpt_TypeList.DataSource = bllType.GetList("");
            Rpt_TypeList.DataBind();
        }


    }
}
